package com.zdj.question;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author zhangdj
 * @date 2022-12-29 15:19
 */

//hide-start
public class Profit {
    public static void main(String[] args) {
//        Object result = ProfitSolution.solution(Integer.parseInt(args[0]), Double.parseDouble(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]));
        Object result = ProfitSolution.solution(266, 9.21, 500000, 266);
        System.out.print(result);
    }
}
//hide-end
class ProfitSolution {

    public static Object solution(int n, double m, int x, int y) {
        // 计算利润的天数
        BigDecimal days = new BigDecimal(String.valueOf(Math.min(y, n)));
        // 本金
        BigDecimal capital = new BigDecimal(String.valueOf(x));
        // 年化收益率
        BigDecimal yield = new BigDecimal(String.valueOf(m / 100));
        return capital.multiply(yield).multiply(days).divide(new BigDecimal(365), RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
    }
}
